<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2017/5/10
 * Time: 14:16
 */

namespace app\commands;


use app\models\Activity;
use app\models\Banner;
use app\utils\BaseUtils;
use yii\console\Controller;
use yii\helpers\FileHelper;

class ActivityController extends Controller {

    public function actionIndex() {
        $where = ['and', ['status' => Activity::STATUS_PENDING], ['>', 'start_time', 0], ['<', 'start_time', time()]];
        Activity::updateAll(['status' => Activity::STATUS_RUNNING], $where);

        $where = ['and', ['<>', 'status', Activity::STATUS_END], ['>', 'end_time', 0], ['<', 'end_time', time()]];
        $row = Activity::updateAll(['status' => Activity::STATUS_END], $where);
        $this->stdout("{$row}\n");

        return static::EXIT_CODE_NORMAL;
    }
}